import {
  GET_REPLAY_MESSAGE_LIST_REQ,
  LESSON_SIGN_REQ,
  GET_LESSONS_REQ,
  GET_ROUND_LIST_REQ,
  GET_ROOM_INFO_REQ,
  SUBMIT_ANSWER_REQ,
  GET_PROBLEM_REQ,
  LESSON_FINISHED_REQ,
  GET_USER_INFO_REQ,
  LEAVE_ROOM_REQ,
  DISCUSS_FINISH_REQ,
  GET_AGORA_TOKEN_REQ,
  DISCUSS_START_REQ,
  USER_PROBLEM_ROUND_PROGRESS_REQ,
  USER_ENTER_NEXT_ROUND_REQ,
  SUBMIT_REPLAY_ANSWER_REQ,
  GET_REPLAY_PROBLEM_REQ,
  LESSON_ASSIST_START_TALK_TO_ALL_REQ,
  LESSON_ASSIST_STOP_TALK_TO_ALL_REQ,
  GET_LESSON_END_PAGE_REQ,
  GET_ROUND_LIST_ON_REVIEW_REQ,
  UPLOAD_USER_INSTANT_ANSWER_REQ,
  USER_EVENT_REPORT_REQ,
  SUBMIT_REPLAY_INSTANT_REQ,
  GET_ROUND_LIST_CACHE_INFO_REQ,
  SHOW_FACE_REQ,
  GET_MESSAGE_LIST_REQ,
  READ_MESSAGE_REQ,
  SEND_MESSAGE_REQ,
  WITH_DRAW_MESSAGE_REQ,
  GET_MESSAGE_REMIND_NUM_REQ,
  READ_TEXT_MESSAGES_REQ,
  GET_STUDENT_OF_PARENT_REQ,
  GET_PLATFORM_STUDENT_REQ
} from '../../service/constant';

import request from '../request';
import { GetLessonsRes } from './getLessons';

import {
  GetLessonsParams,
  GetRoundListParams,
  GetRoomInfoParams,
  SubmitAnswerParams,
  GetProblemParams,
  LessonFinishedParams,
  GetUserInfoParams,
  LeaveRoomParams,
  DiscussFinishParams,
  GetAgoraToken,
  DiscussStartParams,
  UserProblemRoundProgressParams,
  UserEnterNextRoundParams,
  SubmitReplayAnswerParams,
  LessonAssistStartTalkToAllParams,
  LessonAssistStopTalkToAllParams,
  GetLessonEndPageParams,
  UploadUserInstantAnswerParams,
  UserEventReportParams,
  SubmitReplayInstantParams,
  GetRoundListCacheInfoParams,
  LessonSignParams,
  GetMessageListParams,
  ReadMessageParams,
  SendMessageParams,
  GetMessageRemindNumParams,
  ReadTextMessagesParams,
  GetPlatformStudentParams
} from './paramsInterface';
import { GetRoundListRes } from './getRoundList';
import { GetRoomInfoRes } from './getRoomInfo';
import { SubmitAnswerRes } from './submitAnswer';
import { GetProblemRes } from './getProblem';
import { CommonRes } from '../commonRes';
import { GetUserInfoRes } from './getUserInfo';
import { AgoraToken } from './getAgoraToken';
import { SubmitReplayAnswerRes } from './submitReplayAnswer';
import { GetLessonEndPageRes } from './getLessonEndPage';
import { UploadUserInstantAnswerRes } from './uploadUserInstantAnswer';
import { SubmitReplayInstantRes } from './submitReplayInstant';
import { RoundListCacheInfo } from './getRoundListCacheInfo';
import { LessonSignRes } from './lessonSign';
import { GetMessageListRes } from './getMessageList';
import { SendMessageRes } from './sendMessage';
import { GetMessageRemindNumRes } from './getMessageRemindNum';
import { StudentOfParent } from './getStudentOfParent';
import { GetPlatformStudentRes } from './getPlatformStudent';

export default {
  // 获取课程列表
  getLessons: (data: GetLessonsParams): Promise<GetLessonsRes> =>
    request({
      msgId: GET_LESSONS_REQ,
      data,
      param: { needUserId: true }
    }),
  // 获取课程环节列表
  getRoundList: (data: GetRoundListParams): Promise<GetRoundListRes> =>
    request({
      msgId: GET_ROUND_LIST_REQ,
      data
    }),
  // 获取回放课程环节列表
  getRoundListOnReview: (data: GetRoundListParams): Promise<GetRoundListRes> =>
    request({
      msgId: GET_ROUND_LIST_ON_REVIEW_REQ,
      data
    }),
  // 获得房间信息
  getRoomInfo: (
    data: GetRoomInfoParams,
    needLoading?: boolean
  ): Promise<GetRoomInfoRes> =>
    request({
      msgId: GET_ROOM_INFO_REQ,
      data,
      param: {
        needUserId: true,
        needLoading: !!needLoading,
        limitFrequency: false,
        needToast: !!needLoading
      }
    }),
  // 提交互动题答案
  submitAnswer: (
    data: SubmitAnswerParams,
    needLoading = true
  ): Promise<SubmitAnswerRes> =>
    request({
      msgId: SUBMIT_ANSWER_REQ,
      data,
      param: { needUserId: true, needLoading: !!needLoading }
    }),
  // 获取互动题题干
  getProblem: (
    data: GetProblemParams,
    needLoading?: boolean
  ): Promise<GetProblemRes> =>
    request({
      msgId: GET_PROBLEM_REQ,
      data,
      param: { needLoading: !!needLoading }
    }),
  // 课程结束
  lessonFinished: (data: LessonFinishedParams): Promise<CommonRes> =>
    request({
      msgId: LESSON_FINISHED_REQ,
      data,
      param: { needUserId: true }
    }),
  // 获取指定用户展示信息
  getUserInfo: (data: GetUserInfoParams): Promise<GetUserInfoRes> =>
    request({
      msgId: GET_USER_INFO_REQ,
      data
    }),
  // 用户离开房间
  leaveRoom: (data: LeaveRoomParams): Promise<CommonRes> =>
    request({
      msgId: LEAVE_ROOM_REQ,
      data,
      param: { needUserId: true }
    }),
  // 完成讨论
  discussFinish: (data: DiscussFinishParams): Promise<CommonRes> =>
    request({
      msgId: DISCUSS_FINISH_REQ,
      data,
      param: { needUserId: true }
    }),
  // 获取AGORA token
  getAgoraToken: (data: GetAgoraToken): Promise<AgoraToken> =>
    request({
      msgId: GET_AGORA_TOKEN_REQ,
      data,
      param: { needUserId: true }
    }),
  // 开始讨论环节
  discussStart: (data: DiscussStartParams): Promise<CommonRes> =>
    request({
      msgId: DISCUSS_START_REQ,
      data,
      param: { needUserId: true }
    }),
  // 用户互动题环节进度上报
  userProblemRoundProgress: (
    data: UserProblemRoundProgressParams
  ): Promise<CommonRes> =>
    request({
      msgId: USER_PROBLEM_ROUND_PROGRESS_REQ,
      data,
      param: { needUserId: true }
    }),
  // 用户进入下一环节
  userEnterNextRound: (data: UserEnterNextRoundParams): Promise<CommonRes> =>
    request({
      msgId: USER_ENTER_NEXT_ROUND_REQ,
      data,
      param: { needUserId: true }
    }),
  // 提交回放答案
  submitReplayAnswer: (
    data: SubmitReplayAnswerParams,
    needLoading = true
  ): Promise<SubmitReplayAnswerRes> =>
    request({
      msgId: SUBMIT_REPLAY_ANSWER_REQ,
      data,
      param: { needUserId: true, needLoading: !!needLoading }
    }),
  // 获取回放互动题题干
  getReplayProblem: (
    data: GetProblemParams,
    needLoading?: boolean
  ): Promise<GetProblemRes> =>
    request({
      msgId: GET_REPLAY_PROBLEM_REQ,
      data,
      param: { needLoading: !!needLoading }
    }),
  // 辅导老师开始与所有人讲话
  lessonAssistStartTalkToAll: (
    data: LessonAssistStartTalkToAllParams
  ): Promise<CommonRes> =>
    request({
      msgId: LESSON_ASSIST_START_TALK_TO_ALL_REQ,
      data,
      param: { needLoading: true }
    }),
  // 辅导老师结束讲话
  lessonAssistStopTalkToAll: (
    data: LessonAssistStopTalkToAllParams
  ): Promise<CommonRes> =>
    request({
      msgId: LESSON_ASSIST_STOP_TALK_TO_ALL_REQ,
      data,
      param: { needLoading: true }
    }),
  // 获取完成课结算页面
  getLessonEndPage: (
    data: GetLessonEndPageParams
  ): Promise<GetLessonEndPageRes> =>
    request({
      msgId: GET_LESSON_END_PAGE_REQ,
      data,
      param: { needLoading: true }
    }),
  // 上传用户即兴回答的答案
  uploadUserInstantAnswer: (
    data: UploadUserInstantAnswerParams
  ): Promise<UploadUserInstantAnswerRes> =>
    request({
      msgId: UPLOAD_USER_INSTANT_ANSWER_REQ,
      data
    }),
  // 用户事件上报
  userEventReport: (data: UserEventReportParams): Promise<CommonRes> =>
    request({
      msgId: USER_EVENT_REPORT_REQ,
      data
    }),
  // 回放上传用户即兴回答的答案
  submitReplayInstant: (
    data: SubmitReplayInstantParams
  ): Promise<SubmitReplayInstantRes> =>
    request({
      msgId: SUBMIT_REPLAY_INSTANT_REQ,
      data
    }),
  // 获取环节列表缓存信息请求
  getRoundListCacheInfo: (
    data: GetRoundListCacheInfoParams
  ): Promise<RoundListCacheInfo> =>
    request({
      msgId: GET_ROUND_LIST_CACHE_INFO_REQ,
      data
    }),
  // 上课签到
  lessonSign: (data: LessonSignParams): Promise<LessonSignRes> =>
    request({
      msgId: LESSON_SIGN_REQ,
      data
    }),
  // 露脸加金币
  showFace: (data: LessonSignParams): Promise<LessonSignRes> =>
    request({
      msgId: SHOW_FACE_REQ,
      data
    }),
  // 获取聊天记录
  getMessageList: (data: GetMessageListParams): Promise<GetMessageListRes> =>
    request({
      msgId: GET_MESSAGE_LIST_REQ,
      data
    }),
  // 回放获取聊天记录
  getReplayMessageList: (
    data: GetMessageListParams
  ): Promise<GetMessageListRes> =>
    request({
      msgId: GET_REPLAY_MESSAGE_LIST_REQ,
      data
    }),
  // 阅读消息
  readMessage: (data: ReadMessageParams): Promise<CommonRes> =>
    request({
      msgId: READ_MESSAGE_REQ,
      data
    }),
  // 发送消息
  sendMessage: (data: SendMessageParams): Promise<SendMessageRes> =>
    request({
      msgId: SEND_MESSAGE_REQ,
      data
    }),
  // 撤回消息
  withDrawMessage: (data: ReadMessageParams): Promise<CommonRes> =>
    request({
      msgId: WITH_DRAW_MESSAGE_REQ,
      data
    }),
  // 获取聊天消息提醒数量
  getMessageRemindNum: (
    data: GetMessageRemindNumParams
  ): Promise<GetMessageRemindNumRes> =>
    request({
      msgId: GET_MESSAGE_REMIND_NUM_REQ,
      data
    }),
  // 批量阅读文字消息
  readTextMessages: (data: ReadTextMessagesParams): Promise<CommonRes> =>
    request({
      msgId: READ_TEXT_MESSAGES_REQ,
      data
    }),
  // 获取家长对应的学生id
  getStudentOfParent: (): Promise<StudentOfParent> =>
    request({
      msgId: GET_STUDENT_OF_PARENT_REQ
    }),
  // 获取点名上台学生信息
  getPlatformStudent: (
    data: GetPlatformStudentParams
  ): Promise<GetPlatformStudentRes> =>
    request({
      msgId: GET_PLATFORM_STUDENT_REQ,
      data
    })
};
